
package com.jf.cloud.combo.controller.multishop;

import com.jf.cloud.combo.dto.ComboSpuSkuDTO;
import com.jf.cloud.combo.model.ComboSpuSku;
import com.jf.cloud.combo.service.ComboSpuSkuService;
import com.jf.cloud.common.database.dto.PageDTO;
import com.jf.cloud.common.database.vo.PageVO;
import com.jf.cloud.common.response.ServerResponseEntity;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import ma.glasnost.orika.MapperFacade;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * 套装商品sku项
 *
 * @author zz
 * @date 2022-08-16 09:18:06
 */
@RestController("multishopComboProdSkuController")
@RequestMapping("/m/combo_prod_sku")
@Tag(name = "套装商品sku项")
public class ComboProdSkuController {

    @Autowired
    private ComboSpuSkuService comboProdSkuService;

    @Autowired
    private MapperFacade mapperFacade;

    @GetMapping("/page")
    @Operation(summary = "获取套装商品sku项列表" , description = "分页获取套装商品sku项列表")
    public ServerResponseEntity<PageVO<ComboSpuSku>> page(@Valid PageDTO pageDTO) {
        PageVO<ComboSpuSku> comboProdSkuPage = comboProdSkuService.page(pageDTO);
        return ServerResponseEntity.success(comboProdSkuPage);
    }

//    @GetMapping
//    @Operation(summary = "获取套装商品sku项" , description = "根据comboProdId获取套装商品sku项")
//    public ServerResponseEntity<ComboSpuSku> getByComboProdId(@RequestParam Long comboProdId) {
//        return ServerResponseEntity.success(comboProdSkuService.getByComboProdId(comboProdId));
//    }

//    @PostMapping
//    @Operation(summary = "保存套装商品sku项" , description = "保存套装商品sku项")
//    public ServerResponseEntity<Void> save(@Valid @RequestBody ComboProdSkuDTO comboProdSkuDTO) {
//        ComboSpuSku comboProdSku = mapperFacade.map(comboProdSkuDTO, ComboSpuSku.class);
//        comboProdSku.setComboSpuId(null);
//        comboProdSkuService.save(comboProdSku);
//        return ServerResponseEntity.success();
//    }

    @PutMapping
    @Operation(summary = "更新套装商品sku项" , description = "更新套装商品sku项")
    public ServerResponseEntity<Void> update(@Valid @RequestBody ComboSpuSkuDTO comboProdSkuDTO) {
        ComboSpuSku comboProdSku = mapperFacade.map(comboProdSkuDTO, ComboSpuSku.class);
        comboProdSkuService.update(comboProdSku);
        return ServerResponseEntity.success();
    }

//    @DeleteMapping
//    @Operation(summary = "删除套装商品sku项" , description = "根据套装商品sku项id删除套装商品sku项")
//    public ServerResponseEntity<Void> delete(@RequestParam Long comboProdId) {
//        comboProdSkuService.deleteById(comboProdId);
//        return ServerResponseEntity.success();
//    }
}
